﻿using WindowSystem;

namespace WindowsGame
{
    public sealed class Start : Window
    {
        //private WebReferenceManager.ServerConnection serverConnection;
        private Game1 game;
        //private GUIManager gui;

        public Start(Game1 game, GUIManager gui)//, WebReferenceManager.ServerConnection serverConnection)
            : base(game, gui)
        {
            this.game = game;
            //this.gui = gui;
            //this.serverConnection = serverConnection;

            const int width = 200;
            const int height = 120;

            TitleText = "Start";
            Width = width;
            Height = height;
            gui.Add(this);


            var btnNewGame = new TextButton(game, gui) { Text = "New Game", X = 10, Y = 15, Width = 170};
            btnNewGame.Click += (btnNewGame_Click);
            Add(btnNewGame);

            var btnContinueGame = new TextButton(game, gui) { Text = "Continue Game", X = 10, Y = 50, Width = 170 };
            btnContinueGame.Click += (btnContinueGame_Click);
            Add(btnContinueGame);

            CenterWindow();
        }


        void btnNewGame_Click(UIComponent sender)
        {
            var canClose = game.NewGame();
            if (canClose)
                CloseWindow();
        }

        void btnContinueGame_Click(UIComponent sender)
        {
            var canClose = game.ContinueGame();
            if (canClose)
                CloseWindow();
        }

    }
}